package com.ws.shop.util;

import org.springframework.cache.CacheManager;

public class CacheManagerUtil {

	private static CacheManager cacheManager;
	
	public static void putCache(String cacheName,Object key,Object value){
		cacheManager.getCache(cacheName).put(key, value);
	}
	
	public static Object getCache(String cacheName,Object key){
		return cacheManager.getCache(cacheName).get(key);
	}
	
	/**
	 * 删除指定缓存中指定key
	 * @param cacheName
	 * @param key
	 */
	public static void evictCache(String cacheName,Object key){
		cacheManager.getCache(cacheName).evict(key);
	}
	
	/**
	 *  删除指定缓存中所有内容
	 * @param cacheName
	 */
	public static void clearCache(String cacheName){
		cacheManager.getCache(cacheName).clear();
	}
}
